using System.Diagnostics;
using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisDmsSection(DmsSectionWithDescription section, AnalysisTree? parent)
    : AnalysisDeclaration(AnalysisBoundKinds.DmsSection, section, parent)
{
    private readonly List<AnalysisDmsProperty> _properties = [];

    public override DmsSectionWithDescription Syntax { get; } = section;

    public override int ChildrenCount => _properties.Count + 1;

    public override IEnumerable<AnalysisNode> GetChildren() => [NameIdentifier, .._properties];

    internal override void AddChild(AnalysisNode child)
    {
        Debug.Assert(child.BoundKind == AnalysisBoundKinds.DmsProperty);
        _properties.Add((AnalysisDmsProperty)child);
    }
}
